import React, { Component } from 'react'

export default class Count extends Component {
  constructor() {
    super()
    this.state = {
      count: 0,
      msg: 'heiheihei ',
    }
    // 解决办法1
    // this.fn = () => {
    //   this.setState({
    //     count: this.state.count + 1,
    //     msg: '哈哈',
    //   })
    // }
    this.fn = this.fn.bind(this)
  }

  fn() {
    this.setState({
      count: this.state.count + 1,
      msg: '哈哈',
    })
  }

  render() {
    console.log('render函数执行了')
    return (
      <div>
        <p id="count">{this.state.count}</p>
        <p>{this.state.msg}</p>
        <button onClick={this.fn}>计数+</button>
      </div>
    )
  }
}
/*
react.js 

class Component {
    ...忽略
}

React.Component = Component 

export {Component}
export default React



*/
